PLATFORM = os4

####### DEFAULT SETTINGS HERE #######

CFLAGS = -Wall -O3
LFLAGS = -lm

CC = gcc
AR = ar
RANLIB = ranlib
DEBUGLIB =
TARGET = planethively

####### PLATFORM SPECIFIC STUFF HERE #######

ifeq ($(PLATFORM),os4)
CFLAGS += -mcrt=newlib -ggdb -D__SW_SURFACE__
LFLAGS += -use-dynld -lSDL -mcrt=newlib -ggdb
endif

ifeq ($(PLATFORM),win)
CFLAGS += -Dmain=SDL_main -D__HW_ONLY_WINDOWED__
LFLAGS += -mwindows -lmingw32 -lSDLmain -lSDL
TARGET = planethively.exe
endif

ifeq ($(PLATFORM),linux)
LFLAGS += -lSDL
endif

####### SHOULDN'T HAVE TO CHANGE THIS STUFF #######

all: $(TARGET)

# To strip the exe under os4 when using dynamically linked SDL
# use "make strip_os4"
strip_os4:
	strip `nm -u planethively | sed "s/U /-K/"` planethively -R.comment

$(TARGET): main.o hvl_replay.o shapes.o render.o fonts.o text.o scrollbox.o
	$(CC) -o $(TARGET) main.o hvl_replay.o shapes.o render.o fonts.o text.o scrollbox.o $(LFLAGS)

main.o: main.c main.h hvl_replay.h render.h shapes.h text.h
	$(CC) -c main.c -o main.o $(CFLAGS)

shapes.o: shapes.c shapes.h
	$(CC) -c shapes.c -o shapes.o $(CFLAGS) -ffast-math

render.o: render.c render.h shapes.h hvl_replay.h types.h text.h
	$(CC) -c render.c -o render.o $(CFLAGS) -ffast-math

text.o: text.c text.h shapes.h
	$(CC) -c text.c -o text.o $(CFLAGS) -ffast-math

hvl_replay.o: hvl_replay.c hvl_replay.h types.h
	$(CC) -c hvl_replay.c -o hvl_replay.o $(CFLAGS)

fonts.o: fonts.c
	$(CC) -c fonts.c -o fonts.o $(CFLAGS)

scrollbox.o: scrollbox.c
	$(CC) -c scrollbox.c -o scrollbox.o $(CFLAGS)
